﻿using H2.NET.DBUtility;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace H2.NET.Web.Pages.SMD.Service
{
    public class SmdSyncService
    {
        public static int GetTinTingcountBySerialNumber(string sn)
        {
            DbHelperSQL.connectionString = PubConstant.GetConnectionString("smdDB");

            string sql = @" select distinct count(CrmTingtingID) from [AkzoNobelSMD].[dbo].[t_TingtingDeviceMapping] where CrmTingtingID in
  (select EapproveSN2 from [AkzoNobelSMD].[dbo].t_smd_SmdSyncData where SerialNumber=@serialNumber)";
            SqlDataReader reader = DbHelperSQL.ExecuteReader(sql, new SqlParameter("@serialNumber", sn));
            while (reader.Read())
            {
                return Int16.Parse(reader[0].ToString());
            }
            return 0;
        }
    }
}